package com.imooc.Thread;

/**
 * Created by Administrator on 2017/7/17.
 */
public class BaseRunnable implements Runnable {

    private Integer num = 0;
    private String name;

    public BaseRunnable(String name) {
        this.name = name;
    }

    @Override
    public void run() {
        for (int i = 0; i < 16; i++) {
            System.out.println(this.name + ":" + num++);
            try {
                Thread.sleep(8);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException {
        BaseRunnable br = new BaseRunnable("first runnable");
        BaseRunnable br2 = new BaseRunnable("second runnable");
        Thread t1 = new Thread(br);
        Thread t2 = new Thread(br2);
        t1.start();
        Thread.sleep(32);
        t2.start();

    }
}
